home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / ctest259.zip / CCNEW.ASM < prev    next >
Assembly Source File  |  1993-06-07  |  41KB  |  740 lines

  1.              PAGE    ,120
  2.  
  3.             .386p                        ; 80386 code will be used
  4.             .387                         ; need coprocessor, too
  5.  
  6. JMPS        EQU     <JMP SHORT>          ; declare jumps as short
  7. JES         EQU     <JE  SHORT>          ;  since near jumps (+/- 32K)
  8. JBS         EQU     <JB  SHORT>          ;   are default in 386 mode
  9. JNZS        EQU     <JNZ SHORT>          ;    and these cannot execute
  10. JCS         EQU     <JC  SHORT>          ;     on the older CPUs
  11. JZS         EQU     <JZ  SHORT>
  12. JNES        EQU     <JNE SHORT>
  13. JAES        EQU     <JAE SHORT>
  14. JBES        EQU     <JBE SHORT>
  15. JAS         EQU     <JA  SHORT>
  16.  
  17. cpu_i8088   EQU     1
  18. cpu_i8086   EQU     2
  19. cpu_V20     EQU     3
  20. cpu_V30     EQU     4
  21. cpu_i188    EQU     5
  22. cpu_i186    EQU     6
  23. cpu_i286    EQU     7
  24. cpu_i386    EQU     8
  25. cpu_i386sx  EQU     9
  26. cpu_ct38600 EQU     10
  27. cpu_ct38600sx   EQU     11
  28. cpu_486dlc  EQU     12
  29. cpu_486slc  EQU     13
  30. cpu_RapidCAD EQU     14
  31. cpu_i486    EQU     15
  32. cpu_i486SX  EQU     16
  33. cpu_pentium EQU     17
  34.  
  35. ndp_NoCopro EQU     0
  36. ndp_Emul    EQU     1
  37. ndp_i8087   EQU     2
  38. ndp_i80C187 EQU     3
  39. ndp_i80287  EQU     4
  40. ndp_i287XL  EQU     5
  41. ndp_i387    EQU     6
  42. ndp_i387sx  EQU     7
  43. ndp_2C87    EQU     8
  44. ndp_3C87    EQU    10
  45. ndp_3C87sx  EQU    11
  46. ndp_82S87   EQU    12
  47. ndp_83D87   EQU    14
  48. ndp_83S87   EQU    15
  49. ndp_83C87   EQU    16
  50. ndp_83C87s  EQU    17
  51. ndp_38700   EQU    18
  52. ndp_38700sx EQU    19
  53. ndp_i387DX  EQU    20
  54. ndp_RapidCAD EQU   21
  55. ndp_i486    EQU    22
  56. ndp_82S87p  EQU    23
  57. ndp_387plus EQU    25
  58. ndp_83S87p  EQU    26
  59. ndp_emc87   EQU    27
  60. ndp_pentium EQU    28
  61.  
  62.  
  63. STRT_TIM    MACRO
  64.             MOV     AL, 0B4h             ; timer 2 is
  65.             OUT     43h, AL              ;  programmed as a rate generator
  66.             XOR     AL, AL               ; load zero
  67.             OUT     42h, AL              ; reset
  68.             OUT     42h, AL              ;  timer 2
  69.             ENDM
  70.  
  71. STOP_TIM    MACRO
  72.             MOV     AL, 80h              ; timer 2
  73.             OUT     43h, AL              ;  immediately latched
  74.             IN      AL, 42h              ; read LSB
  75.             MOV     BL, AL               ; save LSB
  76.             IN      AL, 42h              ; read MSB
  77.             MOV     BH, AL               ; save MSB
  78.             NEG     BX                   ; negate for timer count
  79.             ENDM
  80.  
  81.  
  82.  
  83. CODE        SEGMENT BYTE USE16 PUBLIC 'CODE'
  84.  
  85.             ASSUME  CS:CODE
  86.  
  87.             PUBLIC  SpeedTest
  88.  
  89.                                          ; declare parameters
  90.  
  91. Debug_Flag  EQU     [BP+24]              ; <> 0, if debugging output desired
  92. Ext_Flag    EQU     [BP+22]              ; zero, if no extended memory
  93. EMS_Flag    EQU     [BP+20]              ; zero, if no expanded memory
  94. BufferPtr   EQU     [BP+16]              ; buffer for EMS u. EXT test
  95. EMS_Base    EQU     [BP+12]              ; address of EMS-frame
  96. ScreenPtr   EQU     [BP+8]               ; start address of video memory
  97. ResultPtr   EQU     [BP+4]               ; pointer to result struct
  98.  
  99.  
  100.                                          ; declare local variables
  101.  
  102. Stat        EQU     [BP-2]               ; mem for 80x87 status word
  103. Ctrl        EQU     [BP-4]               ; mem for 80x87 control word
  104. GDT         EQU     [BP-52]              ; mem for global descriptor table
  105. SystemStat  EQU     [BP-53]              ; mem for system status
  106. SaveCtrl    EQU     [BP-55]              ; original 80x87 control word
  107.  
  108.  
  109.                                          ; declare result record
  110. CPU_NDP_TYP EQU     [SI]
  111. AAMTime     EQU     [SI+2]
  112. MovEvenTime EQU     [SI+6]
  113. BIOSWrTime  EQU     [SI+8]
  114. MovByteTime EQU     [SI+10]
  115. MovEMSTime  EQU     [SI+12]
  116. MovExtTime  EQU     [SI+14]
  117. ScrFillTime EQU     [SI+16]
  118. Dummy2      EQU     [SI+18]
  119. i87Time     EQU     [SI+20]
  120. i287Time    EQU     [SI+22]
  121. MovDblTime  EQU     [SI+24]
  122.  
  123. SpeedTest   PROC    NEAR
  124.             PUSH    BP                   ; save caller's frame pointer
  125.             MOV     BP, SP               ; make new frame pointer
  126.             SUB     SP, 55               ; alloc mem for local variables
  127.             PUSH    DS                   ; save Turbo Pascal's data segment
  128.             PUSHF                        ; save original flag setting
  129.  
  130. $inittimer: CLI                          ; disable interrupts
  131.             CLD                          ; auto increment for string operations
  132.             IN      AL, 61h              ; port B - system control
  133.             MOV     [SystemStat], AL     ; save system status
  134.             AND     AL, 11111101b        ; clear speaker bit (disable speaker)
  135.             OR      AL, 1                ; turn on bit for timer 2 (enable it)
  136.             CMP     AL, [SystemStat]     ; system already configured correctly ?
  137.             JES     $aam                 ; no need to configure it
  138.             OUT     61h, AL              ; reconfigure system (tmr 2 on,spk off)
  139.  
  140. $aam:       CMP     WORD PTR Debug_Flag,0; debugging output desired ?
  141.             JNZS    $aam1                ; no
  142.             MOV     AH, 9                ; #9, print string
  143.             PUSH    CS                   ; load
  144.             POP     DS                   ;  address of
  145.             MOV     DX, OFFSET CS:$dbg2  ;   debugging message
  146.             INT     21h                  ; call DOS, print debugging message
  147.             JMPS    $aam1                ; skip message text
  148.  
  149. $dbg2       DB      'About to perform AAM speed test', 0Dh, 0Ah ,'$'
  150.  
  151. $aam1:      STRT_TIM                     ; start timer 2
  152.             REPT    200
  153.             AAM                          ; execute 200 AAMs
  154.             ENDM
  155.             STOP_TIM                     ; elapsed time of timer 2 in BX
  156.             LDS     SI, ResultPtr        ; pointer to result struct
  157.             MOV     [AAMTime], BX        ; save time for AAMs
  158.  
  159. $begin_test:CMP     WORD PTR Debug_Flag,0; debugging output desired ?
  160.             JNZS    $cpu_ndptst          ; nope
  161.             MOV     AH, 9                ; #9, print string
  162.             PUSH    CS                   ; load
  163.             POP     DS                   ;  address of
  164.             MOV     DX, OFFSET CS:$dbg1  ;   debugging message
  165.             INT     21h                  ; call DOS, print debugging message
  166.             JMPS    $cpu_ndptst          ; skip message text
  167. $dbg1       DB      'About to perform CPU and NDP test', 0Dh, 0Ah ,'$'
  168.  
  169. $cpu_ndptst:LDS     SI, ResultPtr        ; pointer to result struct
  170.             FNSTCW  [SaveCtrl]           ; save original NDP ctrl word
  171.             PUSH    SP                   ; test updating
  172.             POP     AX                   ;  of stackpointer
  173.             CMP     AX, SP               ; stackpointer updated before push ?
  174.             JES     $286_386             ; no, must be 286, 386 or 486
  175.             MOV     AX, 1                ; try to shift
  176.             MOV     CL, 33               ;  accu 33 times
  177.             SHL     AX, CL               ; shift count masked off ?
  178.             JNZS    $186_188             ; yes, must be 186 or 188
  179.             PUSHA                        ; PUSHA executed on 88/86 as JMP $+2
  180.             STC                          ; carry set if V20 or V30
  181.             JCS     $V20_V30             ; yes, must be V20 or V30
  182.             PUSHF                        ; save flags
  183.             POP     AX                   ; pop flags into AX
  184.             AND     AH, 00FH             ; clear bits 12-15 of flag register
  185.             PUSH    AX                   ; put new flags in stack
  186.             POPF                         ; pop into flag register
  187.             PUSHF                        ; put flags on stack
  188.             POP     AX                   ; get flags
  189.             AND     AH, 0F0H             ; test if all bits
  190.             CMP     AH, 0F0H             ;  in highest nibble set
  191.             JES     $88_86               ; all bits in highest nibble set
  192.             XOR     DL, DL               ; failed all tests, unknown CPU
  193.             JMPS    $copro_test          ; go and test NDP
  194. $8